package abstractgame;

import java.util.Observable;
import java.util.Vector;

public abstract class GameState extends Observable {

	public static final int SIDE_BLACK = 0;
	public static final int SIDE_WHITE = 1;
	
	/**
	 * The width of the gameboard
	 */
	private int boardWidth;
	/**
	 * The height of the gameboard
	 */
	private int boardHeight;
	/**
	 * The board
	 */
	protected int[][] board;
	/**
	 * The pieces for white
	 */
	protected Vector<GamePiece> whitePieces = new Vector<GamePiece>();
	/**
	 * The pieces for black
	 */
	protected Vector<GamePiece> blackPieces = new Vector<GamePiece>();

	/**
	 * Creates a new board
	 * 
	 * @param width
	 *            The width of the board
	 * @param height
	 *            The height of the board
	 */
	public GameState(int width, int height) {
		board = new int[width][height];
		boardWidth = width;
		boardHeight = height;

	}

	/**
	 * Checks if index x and y is on the board
	 * 
	 * @param x
	 *            Location along x-axis
	 * @param y
	 *            Location along y-axis
	 * @return False if x or y is outside board <br>
	 *         True if both are within
	 */
	public boolean boardBoundsCheck(int x, int y) {

		if (x < 0 || y < 0 || x > boardWidth || y > boardHeight) {

			return false;
		}
		return true;
	}

	/**
	 * @return the boardWidth
	 */
	public int getBoardWidth() {
		return boardWidth;
	}

	/**
	 * @return the boardHeight
	 */
	public int getBoardHeight() {
		return boardHeight;
	}

	/**
	 * Adds a piece to the board
	 * 
	 * @param p
	 *            The piece
	 * @param side
	 *            The side which owns the piece
	 */
	public abstract void addPiece(GamePiece p, int side);

	/**
	 * @return the whitePieces
	 */
	public Vector<GamePiece> getWhitePieces() {
		return whitePieces;
	}

	/**
	 * @return the blackPieces
	 */
	public Vector<GamePiece> getBlackPieces() {
		return blackPieces;
	}

	/**
	 * Checks what is on a position. (NOT FINISHED)
	 * 
	 * @param Pos
	 *            The position to be checked
	 * @return The piece at the position to be checked. Returns null if position
	 *         is empty.
	 */
	public GamePiece checkPos(int[] Pos) {
		return null;
	}
}
